$proc = Start-Process "F4Tests.exe" -PassThru

$memoryWatcher = Start-Job -ScriptBlock {
    while ($true) {
        Get-Process -Id $args[0] | Select VirtualMemorySize64,PeakVirtualMemorySize64
        Start-Sleep -Seconds 1
    }
} -ArgumentList $proc.Id

# now wait for the process to end
Wait-Process -Id $proc.Id
    
$memoryWatcher.StopJob()
$results = Receive-Job $memoryWatcher

$results | Format-Table